package main

import (
	"fmt"
	"strconv"
	"os"
	"bufio"
)

func convertToBin(n int) string{
	result := ""
	if(n == 0){
		result = "0"
	}
	for;n > 0;n /=2{
		result = strconv.Itoa(n % 2) + result
	}
	return result
}
//省略出事条件
func printFile(filename string){
	file, err := os.Open(filename)
	if err != nil{
		panic(err)
	}

	scanner := bufio.NewScanner(file)

	for scanner.Scan(){
		fmt.Println(scanner.Text())
	}
}

//while
func forerver(){
	for{
		fmt.Println("abc")
	}
}

func main(){
	fmt.Println(
		convertToBin(5),
		convertToBin(13),
		convertToBin(1231242143),
		convertToBin(0),
	)

	printFile("abc.txt")
	forerver()
}
